package com.ruoyi.quartz.task;

import com.ruoyi.system.domain.Food;
import com.ruoyi.system.domain.Shop;
import com.ruoyi.system.mapper.FoodMapper;
import com.ruoyi.system.mapper.ShopMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
/**
 * 定时任务清空月销量
 *
 * @author Wxl
 */
@Component("Takeout")
public class TakeoutTask {
    @Autowired
    private ShopMapper shopMapper;
    @Autowired
    private FoodMapper foodMapper;

    public void empty()
    {
        List<Shop> shopList = shopMapper.selectList(null);
        for (Shop shop : shopList) {
            shop.setMonthSales(0L);
            shopMapper.updateById(shop);
        }
        List<Food> foodList = foodMapper.selectList(null);
        for (Food food : foodList) {
            food.setMonthSales(0L);
            foodMapper.updateById(food);
        }
    }

}
